package com.polaris.live.common.util.loading

import android.content.Context
import com.lxj.xpopup.core.CenterPopupView
import com.polaris.live.common.R
import com.polaris.live.common.databinding.DialogLoadingBinding

/**
 * LoadingDialog
 *
 * @author Created by 半仙 on 2023/9/25/025 11:59
 */
class LoadingDialog(
    context: Context,
    private var message: String? = null
) : CenterPopupView(context) {

    private lateinit var mBinding: DialogLoadingBinding

    override fun getImplLayoutId(): Int {
        return R.layout.dialog_loading
    }

    override fun onCreate() {
        super.onCreate()

        mBinding = DialogLoadingBinding.bind(popupImplView)

        if (message != null) {
            mBinding.message.text = message
        }
    }

    fun setMessage(message: String?) {
        if (this::mBinding.isInitialized) {
            mBinding.message.text = message
        }
        this.message = message
    }
}